package com.jv.spring.init_destroy_bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.stereotype.Component;

@Component
public class TestTransBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
		BeanDefinitionRegistry bdr = (BeanDefinitionRegistry)beanFactory;
		BeanDefinition bd = BeanDefinitionBuilder.genericBeanDefinition(TestTransBean.class).getBeanDefinition();
		bdr.registerBeanDefinition("testTransBean",bd);
	}
}
